import XtxLoading from '@/components/xtx-loading'
import Vue from 'vue'
const Loading = Vue.extend(XtxLoading)
const loading = new Loading()
const loadingVnode = loading.$mount().$el
export default {
  inserted (el) {
    el.style.position = 'relative'
    el.style.minHeight = '400px'
    el.appendChild(loadingVnode)
  },
  componentUpdated (el, binding) {
    if (binding.value) {
      el.appendChild(loadingVnode)
    } else {
      const dom = document.querySelector('.xtx-loading')
      dom && el.removeChild(dom)
    }
  }
}
